package com.acmen.demo.api;

import com.acmen.demo.dto.cmd.UserAdd;
import com.acmen.demo.dto.cmd.UserUpd;
import com.acmen.demo.dto.query.UserListQry;
import com.acmen.demo.dto.query.UserPageQry;
import com.acmen.demo.dto.vo.UserVO;
import com.acmen.demo.service.UserService;
import com.acmen.easyapi.annotation.Module;
import com.acmen.easyapi.annotation.ReqParam;
import com.acmen.easyapi.annotation.RestApi;
import com.acmen.easyapi.model.CustomizePage;
import com.acmen.easyapi.model.Response;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 用户信息RPC接口
 *
 * @author acmen
 */
@RestController
@Module("用户管理RPC")
public class UserRemoteServiceImpl implements UserRemoteService {
    @Resource
    private UserService userService;

    /**
     * 获取用户列表
     */
    @RestApi(name = "用户分页查询",idx = 0,no = "User01",author = "acmen")
    public Response<CustomizePage<UserVO>> selectPage(UserPageQry query) {
        return userService.selectPage(query);
    }

    /**
     * 获取用户列表
     */
    @RestApi(name = "用户列表查询",idx = 1,no = "User02",author = "acmen")
    public Response<List<UserVO>> selectList(UserListQry query) {
        return userService.selectList(query);
    }

    /**
     * 新增用户
     */
    @RestApi(name = "新增用户",idx = 2,author = "acmen")
    public Response create(UserAdd user) {
        return userService.create(user);
    }

    /**
     * 修改用户
     */
    @RestApi(name = "修改用户",idx = 3,author = "acmen")
    public Response update(UserUpd user) {
        return userService.update(user);
    }

    /**
     * 删除用户
     */
    @DeleteMapping("/delete")
    @RestApi(name = "删除用户",idx = 4,author = "acmen")
    public Response delete(List<Long> ids) {
        return userService.delete(ids);
    }


    @RestApi(name = "获取用户详细信息",idx = 5,author = "acmen")
    @GetMapping("/{id}")
    public Response<UserVO> selectById(@ReqParam(label = "ID") Long id) {
        return userService.selectById(id);
    }

}
